package com.ruoyi.tsjData.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.tsjData.domain.plat.DataTshjWsh;
import com.ruoyi.tsjData.service.IDataTshjWshService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提升机-温升测试Controller
 * 
 * @author ruoyi
 * @date 2023-10-25
 */
@RestController
@RequestMapping("/tsjData/wsh")
@Api(value="提升机-温升测试",tags = "提升机-温升测试接口")
public class DataTshjWshController extends BaseController
{
    @Autowired
    private IDataTshjWshService dataTshjWshService;

    /**
     * 查询提升机-温升测试列表
     */
    @PreAuthorize("@ss.hasPermi('tsjData:wsh:list')")
    @GetMapping("/list")
    public TableDataInfo list(DataTshjWsh dataTshjWsh)
    {
        startPage();
        List<DataTshjWsh> list = dataTshjWshService.selectDataTshjWshList(dataTshjWsh);
        return getDataTable(list);
    }

    /**
     * 导出提升机-温升测试列表
     */
    @PreAuthorize("@ss.hasPermi('tsjData:wsh:export')")
    @Log(title = "提升机-温升测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataTshjWsh dataTshjWsh)
    {
        List<DataTshjWsh> list = dataTshjWshService.selectDataTshjWshList(dataTshjWsh);
        ExcelUtil<DataTshjWsh> util = new ExcelUtil<DataTshjWsh>(DataTshjWsh.class);
        util.exportExcel(response, list, "提升机-温升测试数据");
    }

    /**
     * 获取提升机-温升测试详细信息
     */
    @PreAuthorize("@ss.hasPermi('tsjData:wsh:query')")
    @GetMapping(value = "/{wsId}")
    public AjaxResult getInfo(@PathVariable("wsId") Long wsId)
    {
        return success(dataTshjWshService.selectDataTshjWshByWsId(wsId));
    }

    /**
     * 新增提升机-温升测试
     */
    @PreAuthorize("@ss.hasPermi('tsjData:wsh:add')")
    @Log(title = "提升机-温升测试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataTshjWsh dataTshjWsh)
    {
        return toAjax(dataTshjWshService.insertDataTshjWsh(dataTshjWsh));
    }

    /**
     * 修改提升机-温升测试
     */
    @PreAuthorize("@ss.hasPermi('tsjData:wsh:edit')")
    @Log(title = "提升机-温升测试", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataTshjWsh dataTshjWsh)
    {
        return toAjax(dataTshjWshService.updateDataTshjWsh(dataTshjWsh));
    }

    /**
     * 根据id和任务id变更数据状态
     */
    @ApiOperation(value="根据id和任务id变更数据状态")
    @PreAuthorize("@ss.hasPermi('tsjData:wsh:editByIdAndDataId')")
    @PostMapping("/editByIdAndDataId/{dataTaskId}/{wsId}")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "dataTaskId", value = "任务id", required = true, dataType = "Long"),
            @ApiImplicitParam(paramType="query", name = "wsId", value = "温升id", required = true, dataType = "Long"),
    })
    public AjaxResult editByIdAndDataId(@PathVariable("dataTaskId")Long dataTaskId, @PathVariable("wsId") Long wsId) {
        return toAjax(dataTshjWshService.updateDataTshjWshByWshId(dataTaskId, wsId));
    }

    /**
     * 删除提升机-温升测试
     */
    @PreAuthorize("@ss.hasPermi('tsjData:wsh:remove')")
    @Log(title = "提升机-温升测试", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wsIds}")
    @ApiOperation(value="删除提升机-温升测试")
    public AjaxResult remove(@PathVariable Long[] wsIds)
    {
        return toAjax(dataTshjWshService.deleteDataTshjWshByWsIds(wsIds));
    }
}
